<!-- 私募动态 -->
<template>
  <div>
    <div class="title">私募增持</div>
    <table>
      <thead>
        <tr>
          <td>序号</td>
          <td>私募名称</td>
          <td>加仓量</td>
          <td>持股总量</td>
        </tr>
      </thead>
      <tbody>
        <tr v-for="(item, index) in tableData" :key="item.id">
          <td>{{ index + 1 }}</td>
          <td>{{ item.name }}</td>
          <td>{{ item.addNum }}</td>
          <td>{{ item.holdNum }}</td>
        </tr>
      </tbody>
    </table>
  </div>
</template>

<script>
import { getAddhold } from "../api/index";
import { numberFormat } from "../script/util";
export default {
  data() {
    return {
      tableData: [],
    };
  },

  computed: {},
  watch: {
    $route(to, from) {
      this.getStockstat();
    },
  },
  mounted() {
    window.reloadPrivate = ({ stockCode, endDate }) => {
      this.$route.params.stockCode = stockCode;
      this.$route.params.endDate = endDate;
      this.getStockstat();
    };
    this.getStockstat();
  },
  methods: {
    async getStockstat() {
      const { stockCode, endDate } = this.$route.params;
      await getAddhold({ stockCode, endDate }).then((back) => {
        if (back.status == 1) {
          let list = back.data.list;
          this.tableData = list.map((item) => {
            item.addNum = numberFormat(item.addNum);
            item.holdNum = numberFormat(item.holdNum);
            return item;
          });
        }
      });
    },
  },
};
</script>
<style lang="scss" scoped>
.title {
  display: flex;
  justify-content: space-between;
  height: 48px;
  padding-left: 20px;
  font-size: 20px;
  line-height: 48px;
  color: #ff8a00;
  background: rgba(39, 40, 46, 1);
  border: 1px solid rgba(0, 0, 0, 1);
}
table {
  width: 100%;
  td {
    &:first-child {
      text-align: center;
    }
    &:nth-of-type(2) {
      color: #f4f636;
      padding-left: 7px;
    }
    &:nth-of-type(3) {
      text-align: right;
      padding-right: 7px;
    }
    &:nth-of-type(4) {
      text-align: right;
      padding-right: 17px;
    }
  }
  thead {
    background: #232429;
    line-height: 32px;
    font-size: 15px;
    color: #bcbfc4;
    td {
      border: 1px solid #323337;
    }
  }
  tbody {
    td {
      line-height: 32px;
      font-size: 16px;
      border: 1px solid #25262a;
      &:first-child {
        color: #bcbfc4;
      }
      &:nth-of-type(2) {
        color: #f4f636;
      }
      &:nth-of-type(3) {
        color: #02e2f4;
      }
      &:nth-of-type(4) {
        color: #f4f636;
      }
    }
  }
}
</style>
